package cn.swu.cs.lessonfour

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View

class MainActivity : AppCompatActivity() {

    val TAG = "@@MainActivity"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        println("onCreate")
        Log.d(TAG,"onCreate")
        setContentView(R.layout.activity_main)
    }

    override fun onStart() {
        super.onStart()
        println("onStart")
        Log.d(TAG,"onStart")
    }

    override fun onPause() {
        super.onPause()
        println("onPause")
        Log.d(TAG,"onPause")
    }

    override fun onRestart() {
        super.onRestart()
        println("onRestart")
        Log.d(TAG,"onRestart")
    }

    override fun onResume() {
        super.onResume()
        println("onResume")
        Log.d(TAG,"onResume")
    }

    override fun onStop() {
        super.onStop()
        println("onStop")
        Log.d(TAG,"onStop")
    }

    override fun onDestroy() {
        super.onDestroy()
        println("onDestroy")
        Log.d(TAG,"onDestroy")
    }


    fun onClick(view:View){
        Log.i(TAG,"onClick ${view.id}")

        when(view.id){
            R.id.button->{
                val intent = Intent(this,SecondActivity::class.java)
                startActivity(intent)
            }
            R.id.button2->{

            }
        }
    }
}